import request from '@/utils/request'

/**
 * 学科列表
 */
export const getSubjectListAPI = (params) => {
  return request({
    method: 'get',
    url: '/subjects',
    params
  })
}

/**
 * 目录列表
 */

export const getDirectoryListAPI = (subjectID) => {
  return request({
    method: 'get',
    url: '/directorys',
    params: {
      subjectID
    }
  })
}
/**
 * 目录列表
 */

export const getDirectoryListAPI2 = (params) => {
  return request({
    method: 'get',
    url: '/directorys',
    params
  })
}

/**
 * 删除学科
 */
export const delSubjectAPI = (id) => {
  return request({
    method: 'delete',
    url: `/subjects/${id}`
  })
}

/**
 * 新增学科
 *
 */
export const addSubjectAPI = (data) => {
  return request({
    method: 'post',
    url: `/subjects`,
    data
  })
}

/**
 * 学科详情
 */
export const editSubjectAPI = (id) => {
  return request({
    method: 'get',
    url: `/subjects/${id}`
  })
}

/**
 * 学科修改
 */
export const editAPI = (data) => {
  return request({
    method: 'put',
    url: `/subjects/${data.id}`,
    data
  })
}

/**
 * 获取标签列表
 */
export const getTagsListAPI = (params) => {
  return request({
    method: 'get',
    url: '/tags',
    params
  })
}

/**
 * 新增目录
 */
export const addDirAPI = (data) => {
  return request({
    method: 'post',
    url: '/directorys',
    data
  })
}

/**
 * 目录详情
 */
export const getDirDetailAPI = (id) => {
  return request({
    method: 'get',
    url: `/directorys/${id}`
  })
}

/**
 * 目录修改
 */
export const putDirAPI = (id, data) => {
  return request({
    method: 'put',
    url: `/directorys/${id}`,
    data
  })
}
export const updateState = (id, state) => {
  return request({
    method: 'post',
    url: `/directorys/${id}/${state}`
  })
}

/**
 * 标签添加
 */
export const addTagAPI = (data) => {
  return request({
    method: 'post',
    url: '/tags',
    data
  })
}
/**
 * 获取标签详情
 */
export const getTagDetailAPI = (id) => {
  return request({
    method: 'get',
    url: `/tags/${id}`
  })
}

/**
 * 标签修改
 */
export const putTagAPI = (id, data) => {
  return request({
    method: 'put',
    url: `/tags/${id}`,
    data
  })
}

/**
 * 目录删除
 */
export const delDirAPI = (id) => {
  return request({
    method: 'delete',
    url: `/directorys/${id}`
  })
}

/**
 * 标签删除
 */
export const delTagAPI = (id) => {
  return request({
    method: 'delete',
    url: `/tags/${id}`
  })
}
